package org.javabeans;

import java.awt.Component;
import java.beans.BeanInfo;
import java.beans.PropertyDescriptor;
import java.beans.PropertyEditor;

import javax.swing.JFrame;

public class Controller {
   private DeskBean desk=new DeskBean();
   private void init()throws Exception{
	 BeanInfo beanInfo= java.beans.Introspector.getBeanInfo( DeskBean.class );
	 PropertyDescriptor[] propertyDescriptor=beanInfo.getPropertyDescriptors();
	 propertyDescriptor[0].setPropertyEditorClass(ImagePropertyEditor.class );
     PropertyEditor editor=propertyDescriptor[0].createPropertyEditor( desk );
     editor.addPropertyChangeListener( desk );
     Component c=editor.getCustomEditor();
     JFrame jf=new JFrame();
     jf.getRootPane().getContentPane().add( c );
     jf.setSize( 200 , 200 );
     jf.setVisible( true );
   }
   public static void main(String[] args)throws Exception {
	new Controller().init();
}
}

